package com.androidRtc.controller;

import com.androidRtc.dao.RoomDao;
import com.androidRtc.dao.UserDao;
import com.androidRtc.entity.Room;
import com.androidRtc.entity.Users;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class RoomCreateServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String rPassword, roomName, creater;//定义用户名（创建者），房间名和密码
        RoomDao dao = new RoomDao();
        Room room = null;
        int ID = 0;
        PrintWriter out = null;
        rPassword = request.getParameter("Rpassword");
        roomName = request.getParameter("RoomName");
        creater = request.getParameter("creater");
        room = new Room(null,rPassword,roomName,creater);
        ID = dao.add(room);
        response.setContentType("text/html;charset=utf-8");
        out = response.getWriter();
        out.print(ID);
        out.close();
    }
}
